package com.dj.ssm.web;
import com.dj.ssm.entity.Score;
import com.dj.ssm.service.UserService;
import com.dj.ssm.util.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author hzz
 */
@RestController
@RequestMapping("/score")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/show")
    public ResultModel show(){
        try {
            List<Score> scores = userService.showSco();
            return new ResultModel().success(scores);
        }catch (Exception e) {
            e.printStackTrace();
            return new ResultModel().error();
        }


    }

    @RequestMapping("/addScore")
    public ResultModel addScore(Score scores){

        try {
            userService.addScore(scores);
            return new ResultModel().success();
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultModel().error();

        }
    }


}
